home *** CD-ROM | disk | FTP | other *** search
- Path: noc.tor.hookup.net!the-fix.sos.on.ca
- From: <verneb@the-fix.sos.on.ca>
- Date: Tue,16 Jan 96 00:51:40 -0500
- Newsgroups: comp.lang.c
- Subject: Help with simple code
- Message-ID: <tcpnntpd.16.1.16.0.51.40.2781597121.342670@the-fix.sos.on.ca>
- References: <4dbak5$oij@ionews.io.org>
- Organization: the FIX - Kitchener, Ontario CANADA
- NNTP-Posting-Host: the-fix.sos.on.ca
- X-MajorTCP-Version: MajorTCP/IP [1.80-0]
-
- To: INT:jgordon@io.org
-
- Int:jgordon@io.org,
-
- I >Can anyone tell me what's wrong with this piece of code? I lifted it
- I >straight from a textbook.
- I >
- I >Here's the code:
- I >
- I >/* Calculating compound interest */
- I >..h>
- I >..h>
- I >
- I >main()
- I >{
- I > int year;
- I > double amount, principal = 1000, rate = 0.5;
- I >
- I > printf("%4s%21s\n", "Year", "Amount on deposit");
- I >
- I > for (year = 1; year <= 10; year++) {
- I > amount = principal * pow(1.0 + rate, year);
- I > printf("%4d%21.2f\n", year, amount);
- I > }
- I >
- I > return 0;
- I >}
- I >______________________________________________________________
- I >
- I >and here's the error:
- I >
- I >In function `main':
- I >undefined reference to `pow'
- I >
- I >I don't understand. `pow' is a function, not a variable?
- I >Can anyone tell me what's wrong?
- I >
- I >
- I >
- I > y = mon;
- m = bill+POSTAGE;
- r = pow(x,y);
- z = bill*(float)r+POSTAGE;
-
-
- I don't know if this will help but this is how we used or set it up in
- a billing program that I wrote a couple of years ago. It might give
- you an idea or two.
- Verne H. Bohlender
- Box 416, Chesley, Ontario.Ca. N0G 1L0
- verneb@The-Fix.sos.on.ca
- ___
- * UniQWK #2158*
-
-